import { Prisma } from '@prisma/client';
import { Transform } from 'class-transformer';
import { IsDefined, IsNotEmptyObject } from 'class-validator';
import { BaseDto, BaseFindDto, BaseQueryDto } from './base.dto';

export class AdminCreateDto extends BaseDto<Prisma.AdminCreateInput> {}

export class AdminUpdateDto extends BaseDto<Prisma.AdminUpdateInput> {
  @IsDefined({ message: '条件必填' })
  @IsNotEmptyObject({ nullable: false }, { message: '条件参数必填' })
  where: Prisma.AdminWhereUniqueInput;
}

export class AdminRemoveDto {
  @IsDefined({ message: 'ID必填' })
  @Transform(({ value }) => Number(value))
  id: number;
}

export class AdminFindDto extends BaseFindDto<
  Prisma.AdminWhereUniqueInput,
  Prisma.AdminSelect
> {}

export class AdminQueryDto extends BaseQueryDto<Prisma.AdminWhereUniqueInput> {}

export class AdminLoginDto {
  @IsDefined({ message: '账号必填' })
  account: string;

  @IsDefined({ message: '密码必填' })
  pass?: string;
}
